/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Camunda License 1.0. You may not use this file
 * except in compliance with the Camunda License 1.0.
 */
package io.camunda.optimize.service.util;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

public enum ProcessReportDataType {
  RAW_DATA,

  PROC_INST_DUR_GROUP_BY_NONE,
  PROC_INST_DUR_GROUP_BY_NONE_BY_PROCESS,
  PROC_INST_DUR_GROUP_BY_NONE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_START_DATE,
  PROC_INST_DUR_GROUP_BY_START_DATE_BY_VARIABLE,
  PROC_INST_DUR_GROUP_BY_START_DATE_BY_VARIABLE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_START_DATE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_START_DATE_BY_PROCESS,
  PROC_INST_DUR_GROUP_BY_END_DATE,
  PROC_INST_DUR_GROUP_BY_END_DATE_BY_VARIABLE,
  PROC_INST_DUR_GROUP_BY_END_DATE_BY_VARIABLE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_END_DATE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_END_DATE_BY_PROCESS,
  PROC_INST_DUR_GROUP_BY_VARIABLE,
  PROC_INST_DUR_GROUP_BY_VARIABLE_BY_PROCESS,
  PROC_INST_DUR_GROUP_BY_VARIABLE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_VARIABLE_BY_START_DATE,
  PROC_INST_DUR_GROUP_BY_VARIABLE_BY_START_DATE_WITH_PART,
  PROC_INST_DUR_GROUP_BY_VARIABLE_BY_END_DATE,
  PROC_INST_DUR_GROUP_BY_VARIABLE_BY_END_DATE_WITH_PART,

  PROC_INST_FREQ_GROUP_BY_NONE,
  PROC_INST_FREQ_GROUP_BY_START_DATE,
  PROC_INST_FREQ_GROUP_BY_START_DATE_BY_VARIABLE,
  PROC_INST_FREQ_GROUP_BY_START_DATE_BY_PROCESS,
  PROC_INST_FREQ_GROUP_BY_END_DATE,
  PROC_INST_FREQ_GROUP_BY_END_DATE_BY_VARIABLE,
  PROC_INST_FREQ_GROUP_BY_END_DATE_BY_PROCESS,
  PROC_INST_FREQ_GROUP_BY_RUNNING_DATE,
  PROC_INST_FREQ_GROUP_BY_RUNNING_DATE_BY_PROCESS,
  PROC_INST_FREQ_GROUP_BY_VARIABLE,
  PROC_INST_FREQ_GROUP_BY_VARIABLE_BY_PROCESS,
  PROC_INST_FREQ_GROUP_BY_VARIABLE_BY_START_DATE,
  PROC_INST_FREQ_GROUP_BY_VARIABLE_BY_END_DATE,
  PROC_INST_FREQ_GROUP_BY_DURATION,
  PROC_INST_FREQ_GROUP_BY_DURATION_BY_PROCESS,
  PROC_INST_FREQ_GROUP_BY_NONE_BY_PROCESS,

  PROC_INST_PER_GROUP_BY_NONE,

  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_BY_PROCESS,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_START_DATE,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_START_DATE_BY_FLOW_NODE,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_START_DATE_BY_PROCESS,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_END_DATE,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_END_DATE_BY_FLOW_NODE,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_END_DATE_BY_PROCESS,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_DURATION,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_DURATION_BY_FLOW_NODE,
  FLOW_NODE_FREQ_GROUP_BY_VARIABLE,
  FLOW_NODE_FREQ_GROUP_BY_VARIABLE_BY_FLOW_NODE,
  FLOW_NODE_FREQ_GROUP_BY_VARIABLE_BY_PROCESS,
  FLOW_NODE_FREQ_GROUP_BY_FLOW_NODE_DURATION_BY_PROCESS,

  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_BY_PROCESS,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_START_DATE,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_END_DATE,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_START_DATE_BY_FLOW_NODE,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_START_DATE_BY_PROCESS,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_END_DATE_BY_FLOW_NODE,
  FLOW_NODE_DUR_GROUP_BY_FLOW_NODE_END_DATE_BY_PROCESS,
  FLOW_NODE_DUR_GROUP_BY_VARIABLE,
  FLOW_NODE_DUR_GROUP_BY_VARIABLE_BY_FLOW_NODE,
  FLOW_NODE_DUR_GROUP_BY_VARIABLE_BY_PROCESS,

  USER_TASK_FREQ_GROUP_BY_USER_TASK_START_DATE,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_START_DATE_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_START_DATE_BY_ASSIGNEE,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_START_DATE_BY_CANDIDATE_GROUP,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_START_DATE_BY_PROCESS,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_END_DATE,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_END_DATE_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_END_DATE_BY_ASSIGNEE,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_END_DATE_BY_CANDIDATE_GROUP,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_END_DATE_BY_PROCESS,
  USER_TASK_FREQ_GROUP_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_BY_ASSIGNEE,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_BY_CANDIDATE_GROUP,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_BY_PROCESS,
  USER_TASK_FREQ_GROUP_BY_ASSIGNEE,
  USER_TASK_FREQ_GROUP_BY_ASSIGNEE_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_ASSIGNEE_BY_PROCESS,
  USER_TASK_FREQ_GROUP_BY_CANDIDATE,
  USER_TASK_FREQ_GROUP_BY_CANDIDATE_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_CANDIDATE_BY_PROCESS,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_DURATION,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_DURATION_BY_USER_TASK,
  USER_TASK_FREQ_GROUP_BY_USER_TASK_DURATION_BY_PROCESS,

  USER_TASK_DUR_GROUP_BY_USER_TASK_START_DATE,
  USER_TASK_DUR_GROUP_BY_USER_TASK_START_DATE_BY_USER_TASK,
  USER_TASK_DUR_GROUP_BY_USER_TASK_START_DATE_BY_ASSIGNEE,
  USER_TASK_DUR_GROUP_BY_USER_TASK_START_DATE_BY_CANDIDATE_GROUP,
  USER_TASK_DUR_GROUP_BY_USER_TASK_START_DATE_BY_PROCESS,
  USER_TASK_DUR_GROUP_BY_USER_TASK_END_DATE,
  USER_TASK_DUR_GROUP_BY_USER_TASK_END_DATE_BY_USER_TASK,
  USER_TASK_DUR_GROUP_BY_USER_TASK_END_DATE_BY_ASSIGNEE,
  USER_TASK_DUR_GROUP_BY_USER_TASK_END_DATE_BY_CANDIDATE_GROUP,
  USER_TASK_DUR_GROUP_BY_USER_TASK_END_DATE_BY_PROCESS,
  USER_TASK_DUR_GROUP_BY_USER_TASK,
  USER_TASK_DUR_GROUP_BY_USER_TASK_BY_ASSIGNEE,
  USER_TASK_DUR_GROUP_BY_USER_TASK_BY_CANDIDATE_GROUP,
  USER_TASK_DUR_GROUP_BY_USER_TASK_BY_PROCESS,
  USER_TASK_DUR_GROUP_BY_ASSIGNEE,
  USER_TASK_DUR_GROUP_BY_ASSIGNEE_BY_USER_TASK,
  USER_TASK_DUR_GROUP_BY_ASSIGNEE_BY_PROCESS,
  USER_TASK_DUR_GROUP_BY_CANDIDATE,
  USER_TASK_DUR_GROUP_BY_CANDIDATE_BY_USER_TASK,
  USER_TASK_DUR_GROUP_BY_CANDIDATE_BY_PROCESS,

  VARIABLE_AGGREGATION_GROUP_BY_NONE,

  INCIDENT_FREQ_GROUP_BY_NONE,
  INCIDENT_FREQ_GROUP_BY_FLOW_NODE,

  INCIDENT_DUR_GROUP_BY_NONE,
  INCIDENT_DUR_GROUP_BY_FLOW_NODE;

  public static List<ProcessReportDataType> allDateReports() {
    return Arrays.stream(ProcessReportDataType.values())
        .filter(
            type ->
                type.name().toLowerCase(Locale.ENGLISH).endsWith("start_date")
                    || type.name().toLowerCase(Locale.ENGLISH).endsWith("end_date"))
        .collect(Collectors.toList());
  }

  public static List<ProcessReportDataType> allVariableReports() {
    return Arrays.stream(ProcessReportDataType.values())
        .filter(type -> type.name().toLowerCase(Locale.ENGLISH).contains("_variable"))
        .collect(Collectors.toList());
  }

  public static List<ProcessReportDataType> allViewUserTaskReports() {
    return Arrays.stream(ProcessReportDataType.values())
        .filter(type -> type.name().toLowerCase(Locale.ENGLISH).startsWith("user_task_"))
        .collect(Collectors.toList());
  }
}
